"use client"; import { BannerRep, PrizeTypes } from "@/api/home"; import { Card } from "@/components/Card"; import NoticeBox from "@/components/NoticeBox"; import { Tabs } from "antd-mobile"; import clsx from "clsx"; import React, { FC } from "react"; import "swiper/css"; import { Autoplay } from "swiper/modules"; import { Swiper, SwiperSlide } from "swiper/react"; import styles from "./prize.module.scss"; interface Props { data: PrizeTypes[]; notices?: BannerRep[]; type: "list" | "card" | "notice"; } const HomePrize: FC = (props) => { const { data, type, notices } = props; const noticeSwiperRef = React.useRef(null); const [act, setAct] = React.useState(0); const renderData = React.useMemo(() => { if (type !== "notice") return data; const result: any = []; if (!!data?.length) { let bigWin: string[] = []; data.forEach((item) => { bigWin.push( `${item.phone ? item.phone.slice(0, 1) + "*****" + item.phone.slice(-3) : ""} acabou de retirar ${item.amount} R$` ); }); result.push({ dataType: "bigWin", data: bigWin.join("      "), }); } if (!!notices?.length) { notices?.forEach((item) => { result.push({ dataType: "notice", data: item.content, }); }); } return result; }, [data, notices, type]); const noticeEnd = (idx: number) => { if (noticeSwiperRef.current) { const toIndex = idx + 1 >= renderData.length ? 0 : idx + 1; setAct(toIndex); noticeSwiperRef.current?.slideToLoop(toIndex); } }; if (!renderData?.length) return null; if (type === "notice") { return (
{/* */} { noticeSwiperRef.current = swiper; }} style={{ height: "24px" }} > {renderData.map((item: any, index: number) => ( noticeEnd(index)} > ))}
); } return (
{/*
{t("prize")}
*/} {type === "card" && ( <>
Grandes Vitórias Recentes
{data.map((prize, index: number) => (

{prize.phone ? prize.phone.slice(0, 3) + "*****" + prize.phone.slice(-3) : ""}

R${prize.amount}

))}
)} {type === "list" && (
{/* */} {/*
Jogando Agora
52603
*/}
Jogos
Jogador
{/*
Aposta
*/}
Pagamento
{[...(data || []), ...(data || [])].map((prize, index: number) => (
{prize.game_name}
{prize.phone ? prize.phone.slice(0, 3) + "*****" + prize.phone.slice(-3) : ""}
{/*
Aposta
*/}
R${prize.amount}
))}
)}
); }; export default HomePrize;